"""
读取成绩文件计算最高分最低分平均分
"""
def compute_score():
    scores = []
    with open("students_grade","r",encoding="UTF-8") as f:
        for line in f:
            line = line[:-1]
            fields = line.split(",")
            scores.append(int(fields[-1]))

    max_score = max(scores)
    min_score = min(scores)
    avg_score = round(sum(scores)/len(scores),2)
    return max_score,min_score,avg_score
max_score,min_score,avg_score = compute_score()
print(f"成绩文件中最高分是：{max_score},最低分是{min_score},平均分是{avg_score}")
